package com.lotto.manager.admin.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.druid.stat.TableStat.Mode;
import com.lotto.manager.admin.dto.PageDto;
import com.lotto.manager.admin.entity.db.Kithe;
import com.lotto.manager.admin.service.KitheService;
import com.lotto.manager.admin.system.SystemData;
import com.lotto.manager.common.constant.SystemConstant;

/**
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/kithe")
public class KitheController {

	@Autowired
	private KitheService kitheService;
	
	
	@RequestMapping("")
	public String kitheMian(Model model) {
		return "kithe/kitheMain";
	}
	@RequestMapping("manage")
	public String kitheManage(Model model) {
		Kithe kithe = kitheService.findCurrentKithe();
		model.addAttribute("Kithe", kithe);
		return "kithe/kitheManage";
	}
	
	/**
	 * 跳转和查询user时调用此方法
	 * URL: http://host:port/lottomgr/kithe
	 * 
	 * @param model
	 * @param user
	 * @return
	 */
	@RequestMapping("history")
	public String history(Model model,Integer currentPage) {
		//List<UserEntity> list = kitheService.
		//model.addAttribute("userList", list);
		if(null == currentPage){
			currentPage = 0;
		}
		List<Kithe> list =  kitheService.findHistorys(currentPage);
		PageDto<Kithe> pagedto = new PageDto<Kithe>();
		pagedto.setMaxentries(SystemData.maxentries);
		pagedto.setPerPage(SystemConstant.KITHE_PER_PAGE);
		pagedto.setCurrentPage(currentPage);
		pagedto.setData(list);
		model.addAttribute("pagedto", pagedto);
		return "kithe/hislotto";
	}
	
}
